﻿namespace Text2Rss.Web.Controllers
{
	#region Using Directives
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web;
	using System.Web.Mvc;
	using System.ServiceModel.Syndication;
	using NHibernate;
	using Text2Rss.Web.Code;
	using Text2Rss.Web.DtoModels;
	using Text2Rss.Web.Services;
	#endregion

	public class FeedController : BaseController
    {
		#region Constructor
		/// <summary>
		/// Initializes a new instance of the AccountController class
		/// </summary>
		/// <param name="sessionFactory"></param>
		public FeedController(ISessionFactory sessionFactory)
			: base(sessionFactory)
		{

		}
		#endregion

		[Authorize]
		public ActionResult Edit()
		{
			return View();
		}

		[Authorize]
		public ActionResult Edit(EditFeedModel model, HttpPostedFileBase file)
		{
			return View();
		}

		[Authorize]
		public ActionResult Create()
		{
			return View("Edit");
		}

		//public ActionResult Get(Guid feedId)
		//{
		//    SyndicationFeed feed =
		//        new SyndicationFeed(
		//            "LinkinPark Show News",
		//            string.Empty,
		//            new Uri("http://fake.uri"));

		//    feed.Items = LoadFeed();

		//    return new RssActionResult() { Feed = feed };
		//}


		//private List<SyndicationItem> LoadFeed()
		//{
		//    using (ISession session = SessionFactory.OpenSession())
		//    {
		//        var feedService = new FeedService(session, 
		//        return session.CreateCriteria<News>()
		//            .AddOrder(Order.Desc("Date"))
		//            .List<News>()
		//            .Select(
		//                item => new SyndicationItem(
		//                    item.Title,
		//                    item.Content,
		//                    new Uri("http://fake.uri"),
		//                    item.Id.ToString(),
		//                    item.Date))
		//            .ToList<SyndicationItem>();
		//    }
		//}
	}
}
